// --------------------------------------------------------------------------------------------------------------------
// <copyright file="XmlNodeExtensions.cs" company="Roman '4ux-nbIx' Novitsky">
//   Copyright (c) Roman '4ux-nbIx' Novitsky 2009
// </copyright>
// <summary>
//   Defines the XmlNodeExtensions type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace SettingsManager
{
  #region Namespace Imports

  using System.Xml;

  using JetBrains.Util;

  using Properties;

  #endregion


  /// <summary>
  /// Defines <see cref="XmlNode"/> class extension methods.
  /// </summary>
  internal static class XmlNodeExtensions
  {
    #region Public Methods

    /// <summary>
    /// Gets the root settings file node.
    /// </summary>
    /// <param name="xmlDocument">
    /// The XML document.
    /// </param>
    /// <returns>
    /// The root settings file node.
    /// </returns>
    public static XmlElement GetRootSettingsFileNode(this XmlDocument xmlDocument)
    {
      return xmlDocument.SelectSingleElement(Resources.SettingsFileRootNodeName);
    }


    /// <summary>
    /// Gets the Resharper settings node.
    /// </summary>
    /// <param name="xmlDocument">The XML document.</param>
    /// <returns>The Resharper settings node.</returns>
    public static XmlElement GetResharperSettingsNode(this XmlDocument xmlDocument)
    {
      XmlElement rootelement = xmlDocument.GetRootSettingsFileNode();

      return rootelement == null ? null : rootelement[Resources.SettingsFileResharperSettingsNodeName];
    }


    /// <summary>
    /// Gets the sharing settings node.
    /// </summary>
    /// <param name="xmlDocument">The XML document.</param>
    /// <returns>The sharing settings node.</returns>
    public static XmlElement GetSharingSettingsNode(this XmlDocument xmlDocument)
    {
      XmlElement rootelement = xmlDocument.GetRootSettingsFileNode();

      return rootelement == null ? null : rootelement[Resources.SettingsFileSharingSettingsNodeName];
    }

    #endregion
  }
}